function addField(contenedor, id, e, element){
			if (e.keyCode === 13) {
	        	var answers = document.getElementById(contenedor);
				var input = document.createElement("input");
				input.setAttribute('id', id + answers.getElementsByTagName('input').length);
				input.setAttribute('name', id);
				input.setAttribute('class', "answers")
				input.setAttribute('onkeydown','addField(\"'+ answers.id +'\",\"'+id+'\",event,this)');
				var br = document.createElement("br");
				br.setAttribute('name',id + answers.getElementsByTagName('input').length);
				answers.appendChild(br);
				answers.appendChild(input);
				document.getElementById(input.id).focus();
	            return;

    		}else if(e.keyCode === 8 && element.value == ""){
    			var answers = document.getElementById(contenedor);
    			if(answers.getElementsByTagName('input').length === 1){
    				return;
    			}
    			var oldinput = document.getElementById(element.id);
    			var oldspace = document.getElementsByName(element.id)[0];
    			answers.removeChild(oldspace);
    			answers.removeChild(oldinput);
    			var lastItem = answers.getElementsByTagName('input').length;
    			answers.getElementsByTagName('input')[lastItem-1].focus();
    			return;
    		}
			
}

function saveReport(){
	
	alert(document.getElementsByName('goodThing').length);

	$.ajax({  
			type : "POST",
			url : "",
			data : "goodThings=" + document.getElementsByName('goodThing') + "&" +
				   "problems=" + document.getElementsByName('problem') + "&" +
				   "goodIdeas=" + document.getElementsByName('goodIdea') + "&" +
				   "morals=" + document.getElementsByName('moral'),

			beforeSend : function(event, data) {
				
				alert(data);
			},

			success : function(response) {
				// we have the response
				
			},

			error : function(e) {
				
			}
		});
	
}
